package java101;

import java.util.Scanner;

import javax.swing.JOptionPane;

public class Fibonacci {

	
	static Scanner sc = new Scanner(System.in);	
	public static void main(String[] args) {
	
		String input = JOptionPane.showInputDialog
		("How many Fibonacci numbers do you want to print?");
		int goal = Integer.parseInt(input);
		
		int[] fibArray = new int[goal];
		
		fibArray[0] = 0;
		fibArray[1] = 1;
		
		for(int i=2; i < goal; i++) {
			fibArray[i] = fibArray[i-1] + fibArray[i-2];
		}
   
    System.out.println("The first " + goal + " Fibonacci numbers are: ");
    for(int i=0; i< goal; i++){
    	if (i == goal - 1) {
    		System.out.print("and " + fibArray[i] + " (" + (i + 1) + "). ");
    	}
    	else {
            System.out.print(fibArray[i] + " (" + (i + 1) + "), ");
            
    	}
 	}    
 }
	
}
